home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Garbo
/
Garbo.cdr
/
mac
/
cdev
/
sludge.sit
/
Source Code
/
Sludge.c
< prev
next >
Wrap
Text File
|
1999-10-07
|
45KB
|
1,067 lines
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ File Name: SLUDGE.c Ñ
Ñ ---------- Ñ
Ñ Ñ
Ñ Copyright ⌐ 1990 Apple Computer, Inc. All Rights Reserved Ñ
Ñ Ñ
Ñ Description Ñ
Ñ ----------- Ñ
Ñ This file contains most of the C language code for the SLUDGE cdev. Ñ
Ñ Ñ
Ñ The SLUDGE cdev slows down your mac. It does so by making use of Ñ
Ñ the jump trace exception found in the 68020 and 68030 processors. Ñ
Ñ When SLUDGE is turned on, then at every jump trace exception it Ñ
Ñ executes a tight, inert, loop the number of times specified by the Ñ
Ñ SLUDGE factor. Ñ
Ñ Ñ
Ñ Ñ
Ñ Author Date Description Ñ
Ñ ------------------------------------------------------------------ Ñ
Ñ Kevin McEntee 2/20/90 Original Implementation Ñ
Ñ Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Include Files Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
#include <Types.h>
#include <Memory.h>
#include <Quickdraw.h>
#include <TextEdit.h>
#include <Dialogs.h>
#include <Devices.h>
#include <Scrap.h>
#include <Lists.h>
#include "State_Storage_Manager.h"
#include <ToolUtils.h>
#include "Parasite_Manager.h"
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Constants that refer to the Ñ
Ñ controls of the SLUDGE cdev. Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
#define ON_BUTTON 1
#define OFF_BUTTON 2
#define USER_ITEM_SCROLL_BAR_COVER 4
#define THE_SCROLL_BAR 5
#define ABOUT_BUTTON 6
#define ENTIRE_ABOUT_BOX 7
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Other constants Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
#define ON true
#define OFF false
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Function Prototypes. Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
void Handle_Scroll_Bar_Hit(Handle cdevStorage, DialogPtr CPDialog, short numItems);
void Init_On_Off_Button_Manager(DialogPtr CPDialog, short numItems, Handle cdevStorage);
void Turn_On(DialogPtr CPDialog, short numItems, Handle cdevStorage);
void Turn_Off(DialogPtr CPDialog, short numItems, Handle cdevStorage);
void Update_Sludge_Factor_Display(Handle cdevStorage);
void Draw_About_Message();
void Draw_My_Items(Handle cdevStorage, DialogPtr CPDialog, short numItems);
void React_To_About_Button_Hit(Handle cdevStorage, DialogPtr CPDialog, short numItems);
void Hide_The_Controls(DialogPtr CPDialog, short numItems);
void Enable_And_Show_The_Controls(DialogPtr CPDialog, short numItems);
void Close_About_Box(Handle cdevStorage, DialogPtr CPDialog, short numItems);
void Draw_My_BackGround();
void Fill_The_SLUDGE_BackGround_With_DeskTop_Pattern(RgnHandle back_region);
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Identifier: SLUDGECDEV Ñ
Ñ ----------- Ñ
Ñ Ñ
Ñ Description Ñ
Ñ ----------- Ñ
Ñ This function is the main cdev function for the SLUDGE cdev. For Ñ
Ñ more info on cdev routines and their parameters, see Inside Mac V. Ñ
Ñ Ñ
Ñ History Ñ
Ñ ------- Ñ
Ñ Ñ
Ñ Author Date Description Ñ
Ñ ------------------------------------------------------------------ Ñ
Ñ Kevin McEntee 2/20/90 Original Implementation Ñ
Ñ Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
pascal Handle
SLUDGECDEV(short message, short item, short numItems, short CPanelID,
EventRecord *theEvent, Handle cdevStorage, DialogPtr CPDialog)
{
#pragma unused ( theEvent, CPanelID) /* unused formal parameters */
if (message == macDev) return((Handle) 1);
else if (cdevStorage != nil) {
switch (message) {
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Initialize cdev Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
case initDev: /* initialize cdev */
SetUp_State_Storage(&cdevStorage);
if (State_Storage_Allocated(cdevStorage))
{
Clear_About_Box_State(cdevStorage);
Init_On_Off_Button_Manager(CPDialog, numItems, cdevStorage);
Draw_My_Items(cdevStorage, CPDialog, numItems);
Draw_My_BackGround();
Turn_Off(CPDialog, numItems, cdevStorage);
if (Get_On_Off_Error_Condition(cdevStorage))
cdevStorage = (Handle) Get_On_Off_Recommended_CDEV_Return_Value(cdevStorage);
}
break;
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Process hitDev. Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
case hitDev:
switch (item - numItems) {
case ON_BUTTON:
if (!In_About_Box_State(cdevStorage))
{
Turn_On(CPDialog, numItems, cdevStorage);
if (Get_On_Off_Error_Condition(cdevStorage))
cdevStorage = (Handle) Get_On_Off_Recommended_CDEV_Return_Value(cdevStorage);
}
else
Close_About_Box(cdevStorage, CPDialog, numItems);
break;
case OFF_BUTTON:
if (!In_About_Box_State(cdevStorage))
{
Turn_Off(CPDialog, numItems, cdevStorage);
if (Get_On_Off_Error_Condition(cdevStorage))
cdevStorage = (Handle) Get_On_Off_Recommended_CDEV_Return_Value(cdevStorage);
}
else
Close_About_Box(cdevStorage, CPDialog, numItems);
break;
case ENTIRE_ABOUT_BOX:
if (In_About_Box_State(cdevStorage))
Close_About_Box(cdevStorage, CPDialog, numItems);
break;
case ABOUT_BUTTON:
React_To_About_Button_Hit(cdevStorage, CPDialog, numItems);
break;
case USER_ITEM_SCROLL_BAR_COVER:
if (!In_About_Box_State(cdevStorage))
Handle_Scroll_Bar_Hit( cdevStorage, CPDialog, numItems);
else
Close_About_Box(cdevStorage, CPDialog, numItems);
break;
};
break;
case closeDev: /* clean up and dispose */
break;
case nulDev:
break;
case updateDev: /* handle any Update drawing */
Draw_My_Items(cdevStorage, CPDialog, numItems);
Draw_My_BackGround();
break;
case activDev: /* activate any needed items */
break;
case deactivDev: /* deactivate any needed items */
break;
case keyEvtDev: /* respond to keydown */
break;
case macDev:
case undoDev:
break;
case cutDev:
case copyDev:
case pasteDev:
case clearDev:
break;
}
return (cdevStorage);
} /* cdevStorage != nil */
/*
** if cdevStorage = NIL then ControlPanel
** will put up memory error
*/
return (nil);
}
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Identifier: Handle_Scroll_Bar_Hit Ñ
Ñ ----------- Ñ
Ñ Ñ
Ñ Description Ñ
Ñ ----------- Ñ
Ñ This routines handles the manipulations of the scroll bar that is Ñ
Ñ used to set the SLUDGE factor. Since the control panel would only Ñ
Ñ call the SLUDGE cdev with a scroll bar event after a mouseUp, and Ñ
Ñ SLUDGE wanted control after a mouseDown, I implemented a user item Ñ
Ñ with the same rectangle as the scroll bar and wrote this code to Ñ
Ñ operate the scroll bar. Ñ
Ñ Ñ
Ñ History Ñ
Ñ ------- Ñ
Ñ Ñ
Ñ Author Date Description Ñ
Ñ ------------------------------------------------------------------ Ñ
Ñ Kevin McEntee 2/20/90 Original Implementation Ñ
Ñ Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
void Handle_Scroll_Bar_Hit(Handle cdevStorage, DialogPtr CPDialog, short numItems)
{
short itemType;
ControlHandle itemHandle;
Rect itemRect;
Point mouseLoc;
short scroll_bar_part_code;
long i;
GetDItem(CPDialog, THE_SCROLL_BAR + numItems, &itemType, (Handle *) &itemHandle, &itemRect);
GetMouse(&mouseLoc);
scroll_bar_part_code = TestControl(itemHandle, mouseLoc);
switch (scroll_bar_part_code) {
case inUpButton:
while (StillDown())
{
GetMouse(&mouseLoc);
if ( TestControl(itemHandle, mouseLoc) == inUpButton )
{
HiliteControl(itemHandle, inUpButton);
SetCtlValue(itemHandle, GetCtlValue(itemHandle) - 1);
Increment_Sludge_Factor(cdevStorage);
Update_Sludge_Factor_Display(cdevStorage);
i = TickCount() + 4;
while (TickCount() < i)
;
}
else
HiliteControl(itemHandle, 0);
}
HiliteControl(itemHandle, 0);
break;
case inDownButton:
while (StillDown())
{
GetMouse(&mouseLoc);
if ( TestControl(itemHandle, mouseLoc) == inDownButton )
{
HiliteControl(itemHandle, inDownButton);
SetCtlValue(itemHandle, GetCtlValue(itemHandle) + 1);
Decrement_Sludge_Factor(cdevStorage);
Update_Sludge_Factor_Display(cdevStorage);
i = TickCount() + 4;
while (TickCount() < i)
;
}
else
HiliteControl(itemHandle, 0);
}
HiliteControl(itemHandle, 0);
break;
case inThumb:
if (TrackControl(itemHandle, mouseLoc, nil) == inThumb)
{
Set_Sludge_Factor(cdevStorage, 999 - GetCtlValue(itemHandle));
Update_Sludge_Factor_Display(cdevStorage);
}
break;
case inPageUp:
while (StillDown())
{
GetMouse(&mouseLoc);
if (TestControl(itemHandle, mouseLoc) == inPageUp )
{
SetCtlValue(itemHandle, GetCtlValue(itemHandle) - 20);
Set_Sludge_Factor(cdevStorage, 999 - GetCtlValue(itemHandle));
Update_Sludge_Factor_Display(cdevStorage);
i = TickCount() + 4;
while (TickCount() < i)
;
}
}
break;
case inPageDown:
while (StillDown())
{
GetMouse(&mouseLoc);
if (TestControl(itemHandle, mouseLoc) == inPageDown )
{
SetCtlValue(itemHandle, GetCtlValue(itemHandle) + 20);
Set_Sludge_Factor(cdevStorage, 999 - GetCtlValue(itemHandle));
Update_Sludge_Factor_Display(cdevStorage);
i = TickCount() + 4;
while (TickCount() < i)
;
}
}
break;
};
}
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Identifier: Draw_My_Items Ñ
Ñ ----------- Ñ
Ñ Ñ
Ñ Description Ñ
Ñ ----------- Ñ
Ñ This function is called whenever the SLUDGE cdev gets an updateDev Ñ
Ñ message. Ñ
Ñ Ñ
Ñ History Ñ
Ñ ------- Ñ
Ñ Ñ
Ñ Author Date Description Ñ
Ñ ------------------------------------------------------------------ Ñ
Ñ Kevin McEntee 2/20/90 Original Implementation Ñ
Ñ Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
void Draw_My_Items(Handle cdevStorage, DialogPtr CPDialog, short numItems)
{
ControlHandle scroll_bar_handle;
short itemType;
Rect itemRect;
if (In_About_Box_State(cdevStorage))
{
Hide_The_Controls(CPDialog, numItems);
Draw_About_Message();
}
else
{
Update_Sludge_Factor_Display(cdevStorage);
/* draw the scroll bar with the correct thumb position */
GetDItem(CPDialog, THE_SCROLL_BAR + numItems, &itemType, (Handle *) &scroll_bar_handle, &itemRect);
SetCtlValue(scroll_bar_handle, 999 - Get_Sludge_Factor(cdevStorage));
/* draw "SLUDGE Factor:"; I had to draw this string here (instead of making it a DITL item, because of
SLUDGE's unique about box. */
MoveTo(105,155);
DrawString((Str255) "\pSLUDGE Factor:");
}
}
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Identifier: Update_Sludge_Factor_Display Ñ
Ñ ----------- Ñ
Ñ Ñ
Ñ Description Ñ
Ñ ----------- Ñ
Ñ This function draws the numerical SLUDGE factor value. Ñ
Ñ Ñ
Ñ History Ñ
Ñ ------- Ñ
Ñ Ñ
Ñ Author Date Description Ñ
Ñ ------------------------------------------------------------------ Ñ
Ñ Kevin McEntee 2/20/90 Original Implementation Ñ
Ñ Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
void Update_Sludge_Factor_Display(Handle cdevStorage)
{
long local_sludge;
Rect r;
char c1,c2,c3;
/* Get the current value */
HLock(cdevStorage);
local_sludge = ((State_Storage_Pointer) *cdevStorage)->Sludge_Factor;
HUnlock(cdevStorage);
/* calulate character representation of the value */
c1 = (char) ((local_sludge / 100) % 10) + 48;
c2 = (char) ((local_sludge / 10) % 10) + 48;
c3 = (char) (local_sludge % 10) + 48;
/* Draw the value */
r.left = 180;
r.right = 210;
r.top = 140;
r.bottom = 180;
EraseRect(&r);
MoveTo(185,155);
DrawChar(c1);
DrawChar(c2);
DrawChar(c3);
}
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Identifier: Draw_About_Message Ñ
Ñ ----------- Ñ
Ñ Ñ
Ñ Description Ñ
Ñ ----------- Ñ
Ñ This function draws the strings that make up the messages of the Ñ
Ñ SLUDGE about box. Ñ
Ñ Ñ
Ñ History Ñ
Ñ ------- Ñ
Ñ Ñ
Ñ Author Date Description Ñ
Ñ ------------------------------------------------------------------ Ñ
Ñ Kevin McEntee 2/20/90 Original Implementation Ñ
Ñ Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
void Draw_About_Message()
{
StringHandle current_string;
current_string = GetString(1);
MoveTo(105, 90);
DrawString((Str255) *current_string);
current_string = GetString(2);
MoveTo(105, 102);
DrawString((Str255) *current_string);
current_string = GetString(3);
MoveTo(105, 114);
DrawString((Str255) *current_string);
current_string = GetString(4);
MoveTo(105, 126);
DrawString((Str255) *current_string);
current_string = GetString(5);
MoveTo(105, 138);
DrawString((Str255) *current_string);
current_string = GetString(6);
MoveTo(105, 160);
DrawString((Str255) *current_string);
current_string = GetString(7);
MoveTo(105, 172);
DrawString((Str255) *current_string);
current_string = GetString(8);
MoveTo(105, 184);
DrawString((Str255) *current_string);
current_string = GetString(9);
MoveTo(105, 206);
DrawString((Str255) *current_string);
current_string = GetString(10);
MoveTo(105, 228);
DrawString((Str255) *current_string);
}
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Identifier: Close_About_Box Ñ
Ñ ----------- Ñ
Ñ Ñ
Ñ Description Ñ
Ñ ----------- Ñ
Ñ This function erases the message of the about box and re-draws the Ñ
Ñ SLUDGE controls. Ñ
Ñ Ñ
Ñ History Ñ
Ñ ------- Ñ
Ñ Ñ
Ñ Author Date Description Ñ
Ñ ------------------------------------------------------------------ Ñ
Ñ Kevin McEntee 2/20/90 Original Implementation Ñ
Ñ Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
void Close_About_Box(Handle cdevStorage, DialogPtr CPDialog, short numItems)
{
Rect about_box_rect;
about_box_rect.left = 96;
about_box_rect.right = 308;
about_box_rect.top = 74;
about_box_rect.bottom = 239;
Clear_About_Box_State(cdevStorage);
EraseRect(&about_box_rect);
Enable_And_Show_The_Controls(CPDialog, numItems);
DrawControls(CPDialog);
Draw_My_Items(cdevStorage, CPDialog, numItems);
}
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Identifier: React_To_About_Button_Hit Ñ
Ñ ----------- Ñ
Ñ Ñ
Ñ Description Ñ
Ñ ----------- Ñ
Ñ If the about box is currently displayed, this function calls Ñ
Ñ Close_About_Box, otherwise it scrolls away the SLUDGE controls Ñ
Ñ and draws the about box. Ñ
Ñ Ñ
Ñ History Ñ
Ñ ------- Ñ
Ñ Ñ
Ñ Author Date Description Ñ
Ñ ------------------------------------------------------------------ Ñ
Ñ Kevin McEntee 2/20/90 Original Implementation Ñ
Ñ Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
void React_To_About_Button_Hit(Handle cdevStorage, DialogPtr CPDialog, short numItems)
{
Rect scrolling_rect;
RgnHandle My_Scrolling_Update_Region;
RgnHandle Current_Clip_Region;
long i,j;
if (In_About_Box_State(cdevStorage))
Close_About_Box(cdevStorage, CPDialog, numItems);
else
{
scrolling_rect.left = 96;
scrolling_rect.right = 308;
scrolling_rect.top = 74;
scrolling_rect.bottom = 239;
Set_About_Box_State(cdevStorage);
My_Scrolling_Update_Region = NewRgn();
Current_Clip_Region = NewRgn();
for (j=0; j < 57; j++)
{
ScrollRect(&scrolling_rect, 0, 3, My_Scrolling_Update_Region);
GetClip(Current_Clip_Region);
SetClip(My_Scrolling_Update_Region);
Draw_About_Message();
SetClip(Current_Clip_Region);
scrolling_rect.top = scrolling_rect.top + 3;
i = TickCount() + 1;
while (TickCount() < i)
;
}
DisposeRgn(My_Scrolling_Update_Region);
DisposeRgn(Current_Clip_Region);
}
}
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Identifier: Hide_The_Controls Ñ
Ñ ----------- Ñ
Ñ Ñ
Ñ Description Ñ
Ñ ----------- Ñ
Ñ This function marks the controls of the SLUDGE cdev as hidden so Ñ
Ñ they are not displayed by the Control Panel during an update event. Ñ
Ñ You don't want them displayed when the SLUDGE cdev is in the about Ñ
Ñ box state. Ñ
Ñ Ñ
Ñ History Ñ
Ñ ------- Ñ
Ñ Ñ
Ñ Author Date Description Ñ
Ñ ------------------------------------------------------------------ Ñ
Ñ Kevin McEntee 2/20/90 Original Implementation Ñ
Ñ Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
void Hide_The_Controls(DialogPtr CPDialog, short numItems)
{
short itemType;
ControlHandle itemHandle;
Rect itemRect;
GetDItem(CPDialog, THE_SCROLL_BAR + numItems, &itemType, (Handle *) &itemHandle, &itemRect);
HideControl(itemHandle);
GetDItem(CPDialog, ON_BUTTON + numItems, &itemType, (Handle *) &itemHandle, &itemRect);
HideControl(itemHandle);
GetDItem(CPDialog, OFF_BUTTON + numItems, &itemType, (Handle *) &itemHandle, &itemRect);
HideControl(itemHandle);
}
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Identifier: Enable_And_Show_The_Controls Ñ
Ñ ----------- Ñ
Ñ Ñ
Ñ Description Ñ
Ñ ----------- Ñ
Ñ This function marks the controls of the SLUDGE cdev as visible so Ñ
Ñ they are displayed by the Control Panel during an update event. Ñ
Ñ You don't want them displayed when the SLUDGE cdev is not in the Ñ
Ñ about box state. Ñ
Ñ Ñ
Ñ History Ñ
Ñ ------- Ñ
Ñ Ñ
Ñ Author Date Description Ñ
Ñ ------------------------------------------------------------------ Ñ
Ñ Kevin McEntee 2/20/90 Original Implementation Ñ
Ñ Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
void Enable_And_Show_The_Controls(DialogPtr CPDialog, short numItems)
{
short itemType;
ControlHandle itemHandle;
Rect itemRect;
GetDItem(CPDialog, THE_SCROLL_BAR + numItems, &itemType, (Handle *) &itemHandle, &itemRect);
HiliteControl(itemHandle, 0);
ShowControl(itemHandle);
GetDItem(CPDialog, ON_BUTTON + numItems, &itemType, (Handle *) &itemHandle, &itemRect);
HiliteControl(itemHandle, 0);
ShowControl(itemHandle);
GetDItem(CPDialog, OFF_BUTTON + numItems, &itemType, (Handle *) &itemHandle, &itemRect);
HiliteControl(itemHandle, 0);
ShowControl(itemHandle);
}
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Identifier: Draw_My_BackGround Ñ
Ñ ----------- Ñ
Ñ Ñ
Ñ Description Ñ
Ñ ----------- Ñ
Ñ This function draws the background of the SLUDGE cdev. Ñ
Ñ Ñ
Ñ History Ñ
Ñ ------- Ñ
Ñ Ñ
Ñ Author Date Description Ñ
Ñ ------------------------------------------------------------------ Ñ
Ñ Kevin McEntee 2/20/90 Original Implementation Ñ
Ñ Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
void Draw_My_BackGround()
{
Rect nrctRect, shadow_rect;
RgnHandle temp1_region, temp2_region;
RGBColor current_color, op_color;
current_color.red = 0;
current_color.green = 0;
current_color.blue = 0;
RGBForeColor(¤t_color);
PenNormal();
temp1_region = NewRgn();
temp2_region = NewRgn();
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Frame the rects containing the Ñ
Ñ SLUDGE controls. (Theses rects are Ñ
Ñ not 'nrct's because I wanted to Ñ
Ñ draw my fancy background.) Ñ
Ñ AND calculate the region that is Ñ
Ñ everything but these rects. I will Ñ
Ñ fill this region with the backgroundÑ
Ñ pattern. Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
SetRectRgn(temp1_region,89,1, 321, 254); /* all of the cpanel, used by Sludge */
nrctRect.left = 94; /* The big rect with main controls */
nrctRect.right = 310;
nrctRect.top = 73;
nrctRect.bottom = 241;
FrameRect(&nrctRect);
RectRgn(temp2_region, &nrctRect);
DiffRgn(temp1_region, temp2_region, temp1_region);
nrctRect.left = 94; /* The rect with SLUDGE title */
nrctRect.right = 235;
nrctRect.top = 3;
nrctRect.bottom = 67;
FrameRect(&nrctRect);
RectRgn(temp2_region, &nrctRect);
DiffRgn(temp1_region, temp2_region, temp1_region);
nrctRect.left = 241; /* The rect with the 'About' button */
nrctRect.right = 310;
nrctRect.top = 3;
nrctRect.bottom = 67;
FrameRect(&nrctRect);
RectRgn(temp2_region, &nrctRect);
DiffRgn(temp1_region, temp2_region, temp1_region);
/* Draw interesting stuff here */
Fill_The_SLUDGE_BackGround_With_DeskTop_Pattern(temp1_region);
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Shadow the rectangles to give offsetÑ
Ñ look. Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
current_color.red = 0x2000;;
current_color.green = 0x2000;
current_color.blue = 0x2000;
RGBForeColor(¤t_color);
op_color.red = 0x8000;
op_color.green = 0x8000;
op_color.blue = 0x8000;
OpColor(&op_color);
PenSize(1,1);
PenMode(blend);
/* bottom of rect with main controls */
shadow_rect.left = 96;
shadow_rect.right = 310;
shadow_rect.top = 241;
shadow_rect.bottom = 244;
PaintRect(&shadow_rect);
/* side of rect with main controls */
shadow_rect.left = 310;
shadow_rect.right = 313;
shadow_rect.top = 75;
shadow_rect.bottom = 244;
PaintRect(&shadow_rect);
/* bottom of rect with SLUDGE title */
shadow_rect.left = 96;
shadow_rect.right = 235;
shadow_rect.top = 67;
shadow_rect.bottom = 70;
PaintRect(&shadow_rect);
/* side of rect with SLUDGE title */
shadow_rect.left = 235;
shadow_rect.right = 238;
shadow_rect.top = 5;
shadow_rect.bottom = 70;
PaintRect(&shadow_rect);
/* bottom of rect with about button */
shadow_rect.left = 243;
shadow_rect.right = 310;
shadow_rect.top = 67;
shadow_rect.bottom = 70;
PaintRect(&shadow_rect);
/* side of rect with about button */
shadow_rect.left = 310;
shadow_rect.right = 313;
shadow_rect.top = 5;
shadow_rect.bottom = 70;
PaintRect(&shadow_rect);
current_color.red = 0;
current_color.green = 0;
current_color.blue = 0;
RGBForeColor(¤t_color);
PenNormal();
}
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Identifier: Fill_The_SLUDGE_BackGround_With_DeskTop_Pattern Ñ
Ñ ----------- Ñ
Ñ Ñ
Ñ Description Ñ
Ñ ----------- Ñ
Ñ This function fills the background of the SLUDGE cdev with the Ñ
Ñ current desktop pattern. Ñ
Ñ Ñ
Ñ History Ñ
Ñ ------- Ñ
Ñ Ñ
Ñ Author Date Description Ñ
Ñ ------------------------------------------------------------------ Ñ
Ñ Kevin McEntee 2/20/90 Original Implementation Ñ
Ñ Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
void Fill_The_SLUDGE_BackGround_With_DeskTop_Pattern(RgnHandle back_region)
{
Ptr SPMisc2; /* Inside Mac xref */
SPMisc2 = (Ptr) 0x20B;
/* If bit 7 is set for this byte then, a color PixPattern is the background */
/* pattern, otherwise the b&w pattern at $A3C is the background pattern */
if (*SPMisc2 < 0)
FillCRgn(back_region, GetPixPat(16)); /* Use 'ppat'=16 resource in system file */
else
FillRgn(back_region, (Pattern) 0xA3C); /* Use the 'pattern' at location $A3C */
}
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Function Name: Update_On_Off_Button_Display Ñ
Ñ -------------- Ñ
Ñ Ñ
Ñ Description Ñ
Ñ ----------- Ñ
Ñ This command sets the visible condition of the On/Off buttons based Ñ
Ñ on the current value from the state storage manager. Ñ
Ñ Ñ
Ñ History Ñ
Ñ ------- Ñ
Ñ Ñ
Ñ Author Date Description Ñ
Ñ ------------------------------------------------------------------ Ñ
Ñ Kevin McEntee 7/20/89 Original Implementation Ñ
Ñ Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
void Update_On_Off_Button_Display(DialogPtr CPDialog, short numItems, Handle cdevStorage)
{
short itemType;
Rect itemRect;
Handle itemHand;
int On_Off_Value = Get_ONFF_Value(cdevStorage);
if (!Get_On_Off_Error_Condition(cdevStorage))
{
if (On_Off_Value == ON)
{
GetDItem(CPDialog, numItems + ON_BUTTON, &itemType, &itemHand, &itemRect);
SetCtlValue( (ControlHandle) itemHand, 1);
GetDItem(CPDialog, numItems + OFF_BUTTON, &itemType, &itemHand, &itemRect);
SetCtlValue( (ControlHandle) itemHand, 0);
}
else
{
GetDItem(CPDialog, numItems + ON_BUTTON, &itemType, &itemHand, &itemRect);
SetCtlValue( (ControlHandle) itemHand, 0);
GetDItem(CPDialog, numItems + OFF_BUTTON, &itemType, &itemHand, &itemRect);
SetCtlValue( (ControlHandle) itemHand, 1);
}
}
}
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Function Name: Init_On_Off_Button_Manager Ñ
Ñ -------------- Ñ
Ñ Ñ
Ñ Description Ñ
Ñ ----------- Ñ
Ñ This command performs any initialization actions for the On/Off Ñ
Ñ buttons, including calling the button update command and setting Ñ
Ñ the On/Off error condition to false. Ñ
Ñ Ñ Ñ
Ñ History Ñ
Ñ ------- Ñ
Ñ Ñ
Ñ Author Date Description Ñ
Ñ ------------------------------------------------------------------ Ñ
Ñ Kevin McEntee 7/20/89 Original Implementation Ñ
Ñ Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
void Init_On_Off_Button_Manager(DialogPtr CPDialog, short numItems, Handle cdevStorage)
{
Set_On_Off_Error_Condition(cdevStorage, false);
Update_On_Off_Button_Display(CPDialog,numItems,cdevStorage);
}
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Function Name: Turn_On Ñ
Ñ -------------- Ñ
Ñ Ñ
Ñ Description Ñ
Ñ ----------- Ñ
Ñ This command is called when the SLUDGE CDEV receives Ñ
Ñ a hitDev message for the On button. Ñ
Ñ Ñ
Ñ It starts the SLUDGING. Ñ
Ñ Ñ
Ñ History Ñ
Ñ ------- Ñ
Ñ Ñ
Ñ Author Date Description Ñ
Ñ ------------------------------------------------------------------ Ñ
Ñ Kevin McEntee 7/20/89 Original Implementation Ñ
Ñ Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
void Turn_On(DialogPtr CPDialog, short numItems, Handle cdevStorage)
{
int On_Off_Value = Get_ONFF_Value(cdevStorage);
if (!Get_On_Off_Error_Condition(cdevStorage))
{
if (On_Off_Value == OFF)
{
Set_ONFF_Value(cdevStorage, ON);
if (!Get_On_Off_Error_Condition(cdevStorage))
{
Install(cdevStorage, Get_Sludge_Factor(cdevStorage));
Update_On_Off_Button_Display(CPDialog,numItems,cdevStorage);
}
}
}
}
/*ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
Ñ Ñ
Ñ Function Name: Turn_Off Ñ
Ñ -------------- Ñ
Ñ Ñ
Ñ Description Ñ
Ñ ----------- Ñ
Ñ This command is called when the SLUDGE CDEV receives Ñ
Ñ a hitDev message for the Off button. Ñ
Ñ Ñ
Ñ It stops the SLUDGING. Ñ
Ñ Ñ
Ñ History Ñ
Ñ ------- Ñ
Ñ Ñ
Ñ Author Date Description Ñ
Ñ ------------------------------------------------------------------ Ñ
Ñ Kevin McEntee 7/20/89 Original Implementation Ñ
Ñ Ñ
Ñ Ñ
ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ*/
void Turn_Off(DialogPtr CPDialog, short numItems, Handle cdevStorage)
{
int On_Off_Value = Get_ONFF_Value(cdevStorage);
if (!Get_On_Off_Error_Condition(cdevStorage))
{
if (On_Off_Value == ON)
{
Set_ONFF_Value(cdevStorage, OFF);
if (!Get_On_Off_Error_Condition(cdevStorage))
{
remove(cdevStorage);
Update_On_Off_Button_Display(CPDialog,numItems,cdevStorage);
}
}
}
}